package com.w.waiagent;

import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.jasypt.encryption.StringEncryptor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;

@EnableEncryptableProperties // Jasypt加密 让 Spring Boot 在解析配置文件时自动识别并解密带有 指定前缀的值
@SpringBootApplication
public class WAiAgentApplication {

    public static void main(String[] args) {
        ApplicationContext applicationContext = SpringApplication.run(WAiAgentApplication.class, args);

//         获取加密解密工具类
//        Environment environment = applicationContext.getBean(Environment.class);
//        StringEncryptor encryptor = applicationContext.getBean(StringEncryptor.class);
//
//        // 首先获取配置文件里的原始明文信息
//        String oldPassword = environment.getProperty("aliyunai.apiKey");
//
//        // 加密
//        String encryptPassword = encryptor.encrypt(oldPassword);
//        // 解密
//        String decrypt = encryptor.decrypt(encryptPassword);
//
//        // 打印加密前后的结果对比
//        System.out.println("明文密码：" + oldPassword);
//        System.out.println("====================================");
//        System.out.println("加密结果：" + encryptPassword);
//        System.out.println("====================================");
//        System.out.println("解密结果：" + decrypt);
    }

}
